package sctu.edu.java.year2016.team04.baiyunfei.day20160524.chapter4_3;

/**
 *
 * 用while语句计算1+1/2！+1/3！+...1/20!之和
 * Created by DE on 2016/5/24.
 */
public class Chapter4_3 {
    public static void main(String[] args) {
        double sum=0,i=0,n=1,k=1;

        while(k<=20){
            n*=k;
            i=1/n;

            sum+=i;

            k++;


        }
        System.out.println(sum);
    }
}
